import 'package:flutter/material.dart';
import 'package:test01/config/q_theme.dart';
import 'package:test01/pages/category/category.dart';
import 'package:test01/pages/home/home.dart';
import 'package:test01/pages/main/q_bottom.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:test01/pages/my/my.dart';

class MainScreen extends StatefulWidget {
  const MainScreen({Key? key}) : super(key: key);

  @override
  State<MainScreen> createState() => _MainScreenState();
}

class _MainScreenState extends State<MainScreen> {
  int _currentIndex = 0;
  List<Widget> pageList = [
    const HomeScreen(),
    const CategoryScreen(),
    const MyScreen(),
    const MyScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        automaticallyImplyLeading: false,
        elevation: 0,
        backgroundColor: Colors.white,
        title: GestureDetector(
          onTap: () {
            Navigator.pushNamed(context, "/search");
          },
          child: Container(
            decoration: BoxDecoration(
              color: QTheme.qPrimaryColor,
              borderRadius: BorderRadius.circular(10),
            ),
            height: 56.h,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                const Icon(Icons.search, size: 20, color: Colors.black87,),
                Text(
                  "搜索景区",
                  style: TextStyle(fontSize: 23.w, color: Colors.black87),
                ),
              ],
            ),
          ),
        ),
      ),
      body: IndexedStack(
        children: pageList,
        index: _currentIndex,
      ),
      bottomNavigationBar: BottomNavigationBar(
          selectedFontSize: 28.w,
          unselectedFontSize: 28.w,
          type: BottomNavigationBarType.fixed,
          items: QBottom.qBottomNavigationBarItemList,
          currentIndex: _currentIndex,
          onTap: (index) {
            setState(() {
              _currentIndex = index;
            });
          },
        ),
    );
  }
}
